package com.atyjh.reggie.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

/**
 * 结果类
 *
 * @author yjh
 * @since jdk1.8.0_311 2022.06.07
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {

    /**
     * 状态码：1为正确，2为出错
     */
    private Integer code;
    private T data;
    private String msg;

    public static <E> Result<E> success(E data) {
        return new Result<>(1, data, "");
    }

    public static <S> Result<S> error(String msg) {
        return new Result<>(0, null, msg);
    }
}
